package cn.kbyue.exceptiondemo.enums;

import lombok.Getter;

@Getter
public enum LicenceTypeEnum {
    /**
     * 证书类型
     */
    UNKNOWN(-1, "未知"),
    INTERNAL(1, "内部证书"),
    AUTHORITY(2, "权威机构证书"),
    ;

    LicenceTypeEnum(Integer type, String typeName) {
        this.type = type;
        this.typeName = typeName;
    }

    private final Integer type;
    private final String typeName;

    public static LicenceTypeEnum parseOfNullable(Integer type) {
        for (LicenceTypeEnum value : LicenceTypeEnum.values()) {
            if (value.type.equals(type)) {
                return value;
            }
        }
        // return LicenceTypeEnum.UNKNOWN;
        return null;
    }
}
